# 配置一些公用的配置
BANNER_COUNT = 5

from datetime import timedelta

CELERY_BROKER_URL = 'redis://127.0.0.1:6379/0'
# BACKEND配置，使用redis
CELERY_RESULT_BACKEND = 'redis://127.0.0.1:6379/1'
CELERY_ACCEPT_CONTENT = ['json']
CELERY_TASK_SERIALIZER = 'json'
# 结果序列化方案
CELERY_RESULT_SERIALIZER = 'json'
# 任务结果过期时间，秒
CELERY_TASK_RESULT_EXPIRES = 60 * 60 * 24
# 时区配置
CELERY_TIMEZONE = 'Asia/Shanghai'

CELERY_BEAT_SCHEDULE = {
    'add': {
        'task': 'home.tasks.add',
        'schedule': timedelta(seconds=10)
    },
}

# 支付宝支付配置
# 开发阶段地址
# # 后台地址
# BACKEND_URL = 'http://127.0.0.1:8000/'
# # 前台基URL
# LUFFY_URL = 'http://127.0.0.1:8080'
# 后台地址
BACKEND_URL = 'http://www.lea4ning.top:8000/'
# 前台基URL
LUFFY_URL = 'http://www.lea4ning.top:80'
# 支付宝同步异步回调接口配置
# 后台异步回调接口
NOTIFY_URL = BACKEND_URL + "api/v1/order/success/"
# 前台同步回调接口，没有 / 结尾
RETURN_URL = LUFFY_URL + "/pay/success"

# 跨域处理
CORS_ORIGIN_ALLOW_ALL = True
CORS_ALLOW_METHODS = (
    'DELETE',
    'GET',
    'OPTIONS',
    'PATCH',
    'POST',
    'PUT',
    'VIEW',
)

CORS_ALLOW_HEADERS = (
    'XMLHttpRequest',
    'X_FILENAME',
    'accept-encoding',
    'authorization',
    'content-type',
    'dnt',
    'origin',
    'user-agent',
    'x-csrftoken',
    'x-requested-with',
    'Pragma',
    'token',
)

SIMPLE_JWT = {
    'ACCESS_TOKEN_LIFETIME': timedelta(days=7),  # Access Token的有效期
    "AUTH_HEADER_TYPES": ("Bearer",),
}
